package g3pd.gradep.virdgm;

import java.io.*;

public class VirdExecImpl implements VirdExec {
    private static final long serialVersionUID = -8210755766364099469L;
    int [] inputPosAttr;
    String actionAttr;
    
    public void init(String actionAttr, int [] inputPosAttr) {
        this.actionAttr = actionAttr;
        this.inputPosAttr = inputPosAttr;
    }
    
    public Serializable exec(String actionAttr, int [] inputPosAttr) {
        init(actionAttr, inputPosAttr);
        int result = 0;
        
        if( this.actionAttr.equals("sum"))
            result = this.inputPosAttr[0] + this.inputPosAttr[1];
        
        if(this.actionAttr.equals("sub"))
            result = this.inputPosAttr[0] - this.inputPosAttr[1];
        
        System.out.println("calculate");
        
        return result;
    }
}